﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Net.Chirash.Twitter.TwitterClient
{
    public class ListCreateOption
    {
        public string name;
        public ListMode mode;
        public string description;

        public string CreateQueryString()
        {
            var sb = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(name))
            {
                sb.AppendFormat("name={0}&", Uri.EscapeUriString(name));
            }
            if (mode != null)
            {
                sb.AppendFormat("mode={0}&", Uri.EscapeUriString(mode.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(description))
            {
                sb.AppendFormat("description={0}&", Uri.EscapeUriString(description));
            }

            if (sb.Length == 0)
                return "";
            else
                return sb.Remove(sb.Length - 1, 1).ToString();
        }
    }


    public class ListsGetOption
    {
        public long cursor = -1;

        public string ToString()
        {
            var sb = new StringBuilder();
            sb.Append('?');

            if (this.cursor >= -1)
            {
                sb.AppendFormat("cursor={0}&", this.cursor);
            }

            if (sb.Length == 1)
                return "";
            else
                return sb.Remove(sb.Length - 1, 1).ToString();
        }
    }

    public class ListTimelineOption
    {
        public long SinceID;
        public long MaxID;
        public long PerPage;
        public long Page;

        public string ToString()
        {
            var sb = new StringBuilder();
            sb.Append('?');

            if (this.SinceID > 0)
            {
                sb.AppendFormat("since_id={0}&", this.SinceID);
            }
            if (this.MaxID > 0)
            {
                sb.AppendFormat("max_id={0}&", this.MaxID);
            }
            if (this.PerPage > 0)
            {
                sb.AppendFormat("per_page={0}&", this.PerPage);
            }
            if (this.Page > 0)
            {
                sb.AppendFormat("page={0}&", this.Page);
            }

            if (sb.Length > 1)
                return "";
            else
                return sb.Remove(sb.Length - 1, 1).ToString();
        }

    }

}
